﻿
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Utils;
using Settings;
namespace PanasonicWarranty.DAL
{
    public partial class DBSmsMtStatistic
    {
        //// Since this class provides only static methods, make the default constructor private to prevent
        //// instances from being created with "new DBSmsMtStatistic()"
        private DBSmsMtStatistic() { }
        
        public static bool Create(Guid MtGuid, Guid? MoGuid, string ShortCode, string DestAddr, int OperatorID, string Message, int CooperateID, string Status, DateTime SentTime, string CDRIndicator, string MTType, int? RetryOnFailReqTimes, int? RetryOnTimeOutReqTimes, long? RetryOnFailReqDuration, long? RetryOnTimeOutReqDuration)
		{
            try
            {
                using (SqlConnection conn = new SqlConnection(CommonSetting.ConnectionString))
                {
                    int result = SqlHelper.ExecuteNonQuery(conn, "sp_SmsMtStatistic_Insert", MtGuid, MoGuid, ShortCode, DestAddr, OperatorID, Message, CooperateID, Status, SentTime, CDRIndicator, MTType, RetryOnFailReqTimes, RetryOnTimeOutReqTimes, RetryOnFailReqDuration, RetryOnTimeOutReqDuration);
                    return (result > 0);
                }
            }catch(Exception ex){
                throw ex;
            }
		}

		public static bool Update(Guid MtGuid, Guid? MoGuid, string ShortCode, string DestAddr, int OperatorID, string Message, int CooperateID, string Status, DateTime SentTime, string CDRIndicator, string MTType, int? RetryOnFailReqTimes, int? RetryOnTimeOutReqTimes, long? RetryOnFailReqDuration, long? RetryOnTimeOutReqDuration)
		{
            try
            {
                using (SqlConnection conn = new SqlConnection(CommonSetting.ConnectionString))
                {
                    int result = SqlHelper.ExecuteNonQuery(conn, "sp_SmsMtStatistic_Update", MtGuid, MoGuid, ShortCode, DestAddr, OperatorID, Message, CooperateID, Status, SentTime, CDRIndicator, MTType, RetryOnFailReqTimes, RetryOnTimeOutReqTimes, RetryOnFailReqDuration, RetryOnTimeOutReqDuration);
                    return (result > 0);
                }
            }catch(Exception ex){
                throw ex;
            }
		}

		public static bool Delete(Guid MtGuid)
		{
            try
            {
                using (SqlConnection conn = new SqlConnection(CommonSetting.ConnectionString))
                {
                    int result = SqlHelper.ExecuteNonQuery(conn, "sp_SmsMtStatistic_Delete", MtGuid);
                    return (result > 0);
                }
            }catch(Exception ex){
                throw ex;
            }
		}

        public static SqlDataReader GetAll()
        {
            try
            {
                return SqlHelper.ExecuteReader(CommonSetting.ConnectionString, CommandType.StoredProcedure,"sp_SmsMtStatistic_GetByAll");
            }catch(Exception ex){
                throw ex;
            }
        }

        public static SqlDataReader GetByKey(Guid MtGuid)
        {
            try
            {
                return SqlHelper.ExecuteReader(CommonSetting.ConnectionString, "sp_SmsMtStatistic_GetById", MtGuid);
            }catch(Exception ex){
                throw ex;
            }
        }

        public static SqlDataReader GetByTop(string top, string where, string order)
        {
            try
            {
                return SqlHelper.ExecuteReader(CommonSetting.ConnectionString, "sp_SmsMtStatistic_GetByTop", top, where, order);
            }catch(Exception ex){
                throw ex;
            }
        }
	}
}
